package ModelLayer;
import java.util.ArrayList;
/**
 * Write a description of class Dvd here.
 * 
 * @author Pelle Ravn
 * @version 1.0.1
 */
public class Dvd
{
    private int id;
    private String title;
    private String artist;
    private String releaseDate;
    private ArrayList<DvdCopy> dvdCopyList;
    
    public Dvd(int id, String title, String artist, String releaseDate)
    {
        this.id = id;
        this.title = title;
        this.artist = artist;
        this.releaseDate = releaseDate;
        this.dvdCopyList = new ArrayList<DvdCopy>();       
    }
    
    public Dvd() {
        
    }
    
    public int getId() {
        return this.id;
    }
    
    public void setId(int id) {
        this.id = id;
    }
    
    public String getTitle() {
        return this.title;
    }
    
    public void setTitle(String title) {
        this.title = title;
    }
    
    public String getArtist() {
        return this.artist;
    }
    
    public void setArtist(String artist) {
        this.artist = artist;
    }
    
    public String getReleaseDate() {
        return this.releaseDate;
    }  
            
    public void setReleaseDate(String releaseDate) {
        this.releaseDate = releaseDate;
    }
    
    public DvdCopy findNotRentedCopy()
    {
        int i = 0;
        DvdCopy dCopy = null;
        boolean found = false;
        while(i < dvdCopyList.size() && !found)
        {
            DvdCopy dTemp = dvdCopyList.get(i);                 
             
            if(!dTemp.getRented())
            {
                found = true;
                dCopy = dTemp;                 
            }
            i++;
        }
        return dCopy;
    }
    
    public void makeCopy(String serial, String reqDate, double buyPrice) {
        
        DvdCopy dC = new DvdCopy(serial, reqDate, buyPrice);
        dvdCopyList.add(dC);
    }
    
    public void addCopy(DvdCopy dvdCopy)
    {
        dvdCopyList.add(dvdCopy);
    }
        
     
}
